package com.qc.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qc.enity.User;
import com.qc.mapper.UserMapper;
import com.qc.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.Date;
import java.util.List;

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {
    @Autowired
    private UserMapper userMapper;
    public Integer AddUser(Integer userId, String oid, Integer equipment, Integer sex, String phone, String area, String city, String province, Date createTime,String createUser,Date modificationTime,String modificationUser, String userName) {
        User user = new User();
        user.setUserId(userId);
        user.setOid(oid);
        user.setEquipment(equipment);
        user.setSex(sex);
        user.setPhone(phone);
        user.setArea(area);
        user.setCity(city);
        user.setProvince(province);
        user.setCreateUser(createUser);
        user.setCreateTime(createTime);
        user.setModificationTime(modificationTime);
        user.setModificationUser(modificationUser);
        user.setUserName(userName);
        user.setFavorite("123");
        System.out.println(user);
        int rows=userMapper.insert(user);
        System.out.println(user);
        System.out.println(rows);
        return  rows;
    }

    public Integer RemoveUser(String oid) {
        int ans=userMapper.deleteById(oid);
        return ans;
    }

    public User SelectUser(String oid){
        User user=userMapper.selectById(oid);
        return user;
    }

    @Override
    public List<User> SelectFamily(Integer uid) {
        User user = new User() ;
        user.setUserId(uid);
        LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>(user);
        List<User> data = userMapper.selectList(queryWrapper);
        return data;
    }
}
